fix(security): migrate to scratch runtime image and update vulnerable dependencies - #79
fix(security): migrate to scratch runtime image and update vulnerable dependencies#79rkschamer wants to merge 11 commits into
Conversation
30bc7fb to
b1bde83
Compare
|
Do not merge this PR, before we verified in QA that this version is working as expected in QA. We use the image produced by the PR pipeline to deploy this version to QA. |
Because of reported vulnerbilities
Builds and pushes PR images tagged as ghcr.io/sapcc/go-pmtud:pr-<number> to allow testing container images before merge. This file is not managed by go-makefile-maker and will not be overwritten.
* feat(ci): add per-commit SHA tag to PR container image The PR workflow only produces a mutable pr-<number> tag which gets overwritten on every push. Keppel mirror caches won't re-pull the same tag, making it impossible to test updated PR builds. Add an immutable pr-<number>-<sha> tag alongside the existing one so each push produces a unique image reference usable for testing. * fix docker image --------- Co-authored-by: Rene Kschamer <rene.kschamer@sap.com>
Merging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
Verification: binary rule == script ruleThe goal is to confirm that PrerequisitesA root shell on the target node. Either: # node-level shell (host filesystem at /host)
kubectl debug node/<node-name> -it --profile=sysadmin --image=ubuntu -- chroot /host bashor a privileged pod. The binary's pod is Step 1 — deploy this PR and capture what the binary installsAfter rollout: sudo nft list table ip pmtudExpected output: What to compare
The table name difference is intentional (design decision: clean lifecycle ownership). All match semantics and the hook/priority position are identical. Step 2 — verify teardown is cleanAfter the pod is deleted/restarted the table must be gone: sudo nft list tables | grep pmtud # should print nothingStep 3 — Use Metrics to Validate Packet arrivalsum(rate(go_pmtud_recv_packets_total[5m])) — proves nflog group still receives packets ([L92 in pmtud.go](https://github.com/sapcc/go-pmtud/blob/master/internal/nflog/pmtud.go#L92))
sum(rate(go_pmtud_sent_packets_total[5m])) — proves packets are forwarded to each peer ([L145 in pmtud.go](https://github.com/sapcc/go-pmtud/blob/master/internal/nflog/pmtud.go#L145))
rate(go_pmtud_error_total[5m]) — no new errorsNo stale rules accumulate across pod restarts — that was the original bug this PR fixes. |
Fixes security vulnerabilities by eliminating the attack surface of the runtime image and patching reported CVEs in Go dependencies.
Changes:
FROM ubuntutoFROM scratch— no shell, no OS packages, no package-level CVEs in the runtime containeriptables-nft PREROUTING) andrp_filtersysctl management from the init-container shell scripts into the go-pmtud binary (internal/firewall), which was required to drop the shell dependency from the runtime imagegolang.org/x/netv0.47→v0.58,golang.org/x/sysv0.38→v0.47,k8s.io/{api,apimachinery,client-go}v0.35→v0.37,controller-runtimev0.23→v0.24,prometheus/client_golangv1.23→v1.24After merge, sapcc/helm-charts#12636 needs to be merged as well (removes init container and preStop hook; both PRs must land together to avoid duplicate NFLOG rules during rollout).